<template>
  <div>
    <h2>首页</h2>
    <!-- {{ $store.state.item.num }} -->
    <button @click="_addNum">+</button>
    {{ itemNum }}
    <hr>
    这是分类模块num
    <!-- {{ $store.state.cate.num }} -->
    {{ cateNum }}

    <!-- <el-button type="primary">按钮</el-button>
    <el-rate v-model="rate"></el-rate> -->
    <van-button type="primary">按钮</van-button>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  data () {
    return {
      rate: 4
    }
  },
  methods: {
    // ...mapMutations(['item/addNum']),
    ...mapMutations('cate', ['addNum']),
    _addNum () {
      // this.$store.commit('item/addNum', 5)
      // this['item/addNum'](10)
      this.addNum(50)
    }
  },
  mounted () {
    console.log(this.$store)
  },
  computed: {
    ...mapState({
      itemNum: state => state.item.num,
      cateNum: state => state.cate.num
    })
  }
}

</script>

<style lang="scss" scoped>

</style>
